package net.linku.constant;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.metadata.OrderItem;
import lombok.Data;

import java.util.ArrayList;
import java.util.List;

/**
 * 分页的参数定义
 * 实现了 MyBatis-Plus 的 IPage 接口，便于与 MyBatis-Plus 的分页查询集成。
 *
 * @author SilenceTian
 * @date 2024/7/14
 */
@Data
public class PageParam implements IPage<Object> {

    private int currentPage = 1; // 当前页码，默认值为1
    private int pageSize = 10;   // 每页记录数，默认值为10
    private long total;           // 总记录数
    private List<Object> records = new ArrayList<>(); // 当前页的数据
    private List<OrderItem> orders = new ArrayList<>(); // 排序信息

    @Override
    public List<OrderItem> orders() {
        return orders;
    }

    @Override
    public List<Object> getRecords() {
        return records;
    }

    @Override
    public IPage<Object> setRecords(List<Object> records) {
        this.records = records;
        return this;
    }

    @Override
    public long getTotal() {
        return total;
    }

    @Override
    public IPage<Object> setTotal(long total) {
        this.total = total;
        return this;
    }

    @Override
    public long getSize() {
        return pageSize;
    }

    @Override
    public IPage<Object> setSize(long size) {
        this.pageSize = (int) size;
        return this;
    }

    @Override
    public long getCurrent() {
        return currentPage;
    }

    @Override
    public IPage<Object> setCurrent(long current) {
        this.currentPage = (int) current;
        return this;
    }
}
